package com.ai.wxy.spring.user.controller;

import com.ai.spring.common.annotation.RequestParam;
import com.ai.spring.common.enums.ParamScope;
import com.ai.spring.common.util.ResponseResult;
import com.ai.wxy.spring.service.api.ServiceCaller;
import com.ai.wxy.spring.service.api.dto.ServiceContext;
import com.ai.wxy.spring.service.api.dto.ServiceResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 自定义参数测试
 *
 * @author 石头
 * @Date 2019/11/18
 * @Version 1.0
 **/
@RestController
@RequestMapping(value = "/test")
public class TestController {
    @Autowired
    private ServiceCaller serviceCaller;

    @RequestMapping(value = "/executeByPath/{queryId}",method = RequestMethod.GET)
    public ResponseResult<ServiceResult> excuteByPath(@RequestParam(scope = ParamScope.PATH) ServiceContext context){
        ResponseResult<ServiceResult> response = serviceCaller.excute(context);
        return response;
    }

    @RequestMapping(value = "/excuteByBody",method = RequestMethod.POST)
    public ResponseResult<ServiceResult> excuteByBody(@RequestParam(scope = ParamScope.REQ_BODY) ServiceContext context){
        ResponseResult<ServiceResult> response = serviceCaller.excute(context);
        return response;
    }

    @RequestMapping(value = "/excuteByParam",method = RequestMethod.POST)
    public ResponseResult<ServiceResult> excuteByParam(@RequestParam ServiceContext context){
        ResponseResult<ServiceResult> response = serviceCaller.excute(context);
        return response;
    }
}
